package com.songlanyun.modules.memberbill.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.songlanyun.common.enums.BillConstant;
import com.songlanyun.common.enums.UserBillConstant;
import com.songlanyun.common.utils.custom.DateCustomUtils;
import lombok.Data;

import java.math.BigDecimal;
import java.io.Serializable;

/**
 * 充值卡账单
 *
 * @author Mark
 * @email sunlightcs@gmail.com
 * @date 2020-11-16 14:58:05
 */
@Data
@TableName("yxt_sale_refill_card_bill")
public class SaleRefillCardBillEntity implements Serializable {
    private static final long serialVersionUID = 1L;


    {
        refillOrderCode = "";
        saleOrderCode = "";
        innerMode = BillConstant.InnerMode.EMPTY;
        outerMode = BillConstant.OuterMode.EMPTY;
    }

    /**
     *
     */
    @TableId
    private Long id;
    /**
     * 帐单说明
     */
    private String remark;
    /**
     * 账单类型（0，支出，1收入）
     */
    private BillConstant.BillMode billType;
    /**
     * 入帐前的余额
     */
    private BigDecimal entryBeforeBalance;
    /**
     * 入帐后的余额
     */
    private BigDecimal entryAfterBalance;
    /**
     * 入帐的额度
     */
    private BigDecimal entryValue;
    /**
     * 充值订单编号或退款余回退
     */
    private String refillOrderCode;
    /**
     * 消费订单编号
     */
    private String saleOrderCode;
    /**
     * 收入的行为模式（0空，1充值，2订单退款余额回退，3服务退款余额回退）
     */
    private BillConstant.InnerMode innerMode;
    /**
     * 支出的行为模式（0空，1消费）
     */
    private BillConstant.OuterMode outerMode;

    @TableField(exist = false)
    private String mode;

    public String getMode() {
        if (BillConstant.BillMode.EXPENDITURE == this.billType) {
            this.mode = outerMode.getMsg();
        } else {
            this.mode = innerMode.getMsg();
        }
        return this.mode;
    }
    /**
     * 创建帐户的时间戳
     */
    private Long createTimeMillis;
    public void  setCreateTimeMillis(Long createTimeMillis)
    {
        this.createTimeMillis= createTimeMillis;
        this.formatCreateTimeMillis = DateCustomUtils.formatToDateTimeString(createTimeMillis);
    }

    /**
     * 格式化创建时间
     */
    @TableField(exist =  false)
    private String formatCreateTimeMillis;
    /**
     * 会员id
     */
    private Long userId;

}
